import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import './style.css'
import 'element-plus/theme-chalk/index.css'
const app=createApp(App)
app.use(router)
//定义clickOutSide指令
app.directive('clickOutSide',{
    beforeMount:(el,binding)=>{
        //console.log(binding)
        el.onClickOutSide=(e:MouseEvent)=>{
            if(el.contains(e.target)||el==e.target)return
            if(typeof binding.value=='function'){
                binding.value&&binding.value()
            }else{
                binding.value.handler&&binding.value.handler(binding.value.param)
            }
        }
        document.addEventListener('click',el.onClickOutSide)
    },
    unmounted:(el)=>{
        document.removeEventListener('click', el.onClickOutSide)
    }
})
app.mount('#app')